﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Pixysoft.Framework.Comet.Core
{
    class CometMessage : ICometMessage
    {
        string messageCode;//信息编码 由服务器决定
        string senderCode;//发送者编码 由发送者决定
        string receiverCode;//接受者编码 接受者决定

        byte[] content = new byte[] { 0 };//信息内容
        long timestamp = long.MinValue;//信息的时间戳 用于连续发送时候排序
        DateTime createDate = DateTime.MinValue;//创建时间 由发送者决定
        DateTime modiDate = DateTime.MinValue;//修改时间 由服务器决定        

        string contentType = StringHelper.default_contenttype;//image/gif
        string content_Disposition = null;//默认是空
        string content_Length = null;//文件长度
        string filename = null;//发送的文件名

        public string MessageCode
        {
            get { return messageCode; }
            set { messageCode = value; }
        }
        public string SenderCode
        {
            get { return senderCode; }
            set { senderCode = value; }
        }
        public string ReceiverCode
        {
            get { return receiverCode; }
            set { receiverCode = value; }
        }
        public byte[] Content
        {
            get { return content; }
            set { content = value; }
        }

        public long TimeStamp
        {
            get { return timestamp; }
            set { timestamp = value; }
        }
        public DateTime CreateDate
        {
            get { return createDate; }
            set { createDate = value; }
        }
        public DateTime ModiDate
        {
            get { return modiDate; }
            set { modiDate = value; }
        }

        public string Content_Disposition
        {
            get { return content_Disposition; }
            set { content_Disposition = value; }
        }
        public string ContentType
        {
            get { return contentType; }
            set { contentType = value; }
        }
        public string Content_Length
        {
            get { return content_Length; }
            set { content_Length = value; }
        }
        public string Filename
        {
            get { return filename; }
            set { filename = value; }
        }


        public int CompareTo(ICometMessage other)
        {
            if (this.timestamp > other.TimeStamp)
                return 1;

            else if (this.timestamp == other.TimeStamp)
                return 0;

            return -1;
        }
    }
}
